<template>
	<view class="place-order-tabbar-component">
		<view class="tabbar-placeholder"></view>	
		<view class="tabbar-body">
			<view class="tabbar-content">
				<view class="evaluate-prices">
					<text>预估价：</text>
					<text class="prices-txt">¥{{ activityTotal }}</text>
				</view>
				<view
					class="prices-detail-btn"
					@click="open"
				>
					<image class="icon-up" src="@/static/images/icon_prices_up.png"></image>
					<text>明细</text>
				</view>
				<view
					class="place-order-btn"
					@click="submit"
				>
					<text>提交订单</text>
				</view>
			</view>
		</view>
		<uv-popup
			ref="detailPopup"
			mode="bottom"
			bgColor="transparent"
			:closeOnClickOverlay="true"
			:safeAreaInsetBottom="false"
		  @close="close"
		>
			<view class="prices-detail-content">
				<view class="prices-detail-header">
					<view class="title">价格明细</view>
					<image
						class="icon-close"
						src="https://s1.huishoubao.com/static/wechatMini/icon_close.png"
						@click="close"
					></image>
				</view>
				<view class="prices-detail-body">
					<view class="prices-detail-item">
						<text>本机预估价</text>
						<text>¥{{ quotationValue }}</text>
					</view>
					<view class="prices-detail-item">
						<text>优惠总价</text>
						<text>¥{{ addCouponValue }}</text>
					</view>
					<view class="prices-detail-total">
						<text>预估价总计：</text>
						<text class="total-txt">¥{{ activityTotal }}</text>
					</view>
					<view
						class="prices-detail-btn"
						@click="submit('detail')"
					>
						<text>提交订单</text>
					</view>
				</view>
			</view>
		</uv-popup>
	</view>	
</template>

<script>
export default {
	props: {
		evInfo: Object,
		discountInfo: Object
	},
	computed: {
		quotationValue () {
			return this.evInfo.quotation / 100 || 0
		},
		addCouponValue () {
			return (this.discountInfo.addConpous?.couponMoney / 100 || 0) + (this.discountInfo.useConpous?.couponsValue / 100 || 0)
		},
		activityTotal () {
			return this.quotationValue + this.addCouponValue
		}
	},
	methods: {
		open () {
			this.$refs.detailPopup.open()
		},
		close () {
			this.$refs.detailPopup.close()
		},
		submit (from) {
			if (from === 'detail') {
				this.close()
			}
			this.$emit('submit')
		}
	}
}
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>